package com.zhangxu.microservice.auth.vo.req;

import com.zhangxu.microservice.auth.common.enums.ResourceTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Data;

/**
 * 更新资源请求
 */
@Data
@Schema(description = "更新资源请求")
public class UpdateResourceReq {

    @Schema(description = "所属系统ID", example = "1")
    @NotNull(message = "所属系统ID不能为空")
    private Long systemId;

    @Schema(description = "父资源ID，顶级为0", example = "0")
    @NotNull(message = "父资源ID不能为空")
    private Long parentId;

    @Schema(description = "资源名称", example = "用户管理")
    @NotBlank(message = "资源名称不能为空")
    @Size(max = 50, message = "资源名称长度不能超过50个字符")
    private String name;

    @Schema(description = "资源编码，唯一标识", example = "USER_MANAGE")
    @NotBlank(message = "资源编码不能为空")
    @Pattern(regexp = "^[A-Z_]+$", message = "资源编码只能包含大写字母和下划线")
    @Size(max = 50, message = "资源编码长度不能超过50个字符")
    private String code;

    @Schema(description = "资源类型：MENU/BUTTON/API", example = "MENU")
    @NotNull(message = "资源类型不能为空")
    private ResourceTypeEnum type;

    @Schema(description = "资源路径，如菜单路由/接口路径", example = "/user/list")
    @Size(max = 255, message = "资源路径长度不能超过255个字符")
    private String path;

    @Schema(description = "请求方法，仅对API有效，如GET/POST/PUT/DELETE", example = "GET")
    @Size(max = 10, message = "请求方法长度不能超过10个字符")
    private String method;

    @Schema(description = "是否可见：false-隐藏，true-可见（对菜单类有效）", example = "true")
    private Boolean visible;

    @Schema(description = "排序值，升序", example = "1")
    private Integer sort;

    @Schema(description = "备注说明", example = "用户管理菜单")
    @Size(max = 255, message = "备注说明长度不能超过255个字符")
    private String remark;
}